var data = [
  {
    field1: '华天小区建筑材料检测',
    field2: '交通工程-沥青混合料-乳化沥青残留物含量',
    field3: '试验中',
    field4: '1天2小时2分'
  },
  {
    field1: '华天小区建筑材料检测',
    field2: '交通工程-沥青混合料-乳化沥青残留物含量',
    field3: '内部审核',
    field4: '1天2小时2分'
  },
  {
    field1: 'G220路基材料检测',
    field2: '交通工程-沥青混合料-乳化沥青残留物含量',
    field3: '质控部审核',
    field4: '58分'
  },
];

var data2 = [
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  },
  {
    field0: 'G220一级道路工程',
    field1: '2016.08.15',
    field2: '13',
    field3: '24',
    field4: '25',
    field5: '23'
  }
];

var checkMonthDataX = ['土工','矿粉','水泥','钢筋','煤炭'];
var checkMonthDataY = [240,200,180,140,120];

function clickOperate(id, row) {
  var roleIds = row.roleIds;
  // 传值给click事件
  return "<a class='qn-check J_menuItem' href='pages/taskDetail.html?id=1'>查看</a>" +
         "<a class='qn-check' href='pages/taskDetail.html?id=2'>提交结果</a>";
}

// 饼图
option1 = {
  tooltip : {
    trigger: 'item',
    formatter: "{a} <br/>{b} : {c} ({d}%)"
  },
  legend: {
    orient: 'vertical',
    left: 'left',
    data: ['格式不正确','填写不完整','错别字','附件不齐全','填写不正规']
  },
  color: ['#fe6f4d', '#fdc638', '#2de88e', '#a8a8a8', '#44cede', '#299be4'],
  series : [
    {
      name: '当天日期',
      type: 'pie',
      radius : '55%',
      center: ['50%', '60%'],
      data:[
        {value:335, name:'格式不正确'},
        {value:310, name:'填写不完整'},
        {value:234, name:'错别字'},
        {value:135, name:'附件不齐全'},
        {value:1548, name:'填写不正规'}
      ],
      itemStyle: {
        emphasis: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
};

// 柱状图
option2 = {
  color: ['#6dcbe4'],
  tooltip : {
    trigger: 'axis'
  },
  legend: {
    left:20,
    top:0,
    data:['巡查问题月度环比']
  },
  toolbox: {
    show : true,
    feature : {}
  },
  calculable : true,
  xAxis : [
    {
      type : 'category',
      data : checkMonthDataX,
    }
  ],
  yAxis : [
    {
      type : 'value',
    }
  ],
  series : [
    {
      name:'数量',
      type:'bar',
      data: checkMonthDataY,
      barWidth : 30,
      label: {
        normal: {
          show: true,
          position: 'top',
        }
      },
    }
  ]
};

// 折线图
option3 = {
  tooltip : {
    trigger: 'axis'
  },
  legend: {
    data:['建筑材料','交通工程']
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis : [
    {
      type : 'category',
      boundaryGap : false,
      data : ['6月','7月','8月','9月','10月','11月']
    }
  ],
  yAxis : [
    {
      type : 'value'
    }
  ],
  series : [
    {
      name:'建筑材料',
      type:'line',
      data:[120, 132, 101, 134, 90, 230]
    },
    {
      name:'交通工程',
      type:'line',
      data:[220, 182, 191, 234, 290, 330]
    }
  ]
};

$(document).ready(function() {
  let myChart1 = echarts.init(document.getElementById('result-problem'));
  myChart1.setOption(option1);

  let myChart2 = echarts.init(document.getElementById('check-list'));
  myChart2.setOption(option2);

  let myChart3 = echarts.init(document.getElementById('month-check'));
  myChart3.setOption(option3);

  var $table = $('#index-table');
  $table.bootstrapTable({
    data: data,
    pagination: true,
    pageSize: 10
  });

  var $table = $('#statistics-table');
  $table.bootstrapTable({
    data: data2,
    pagination: true,
    pageSize: 10
  });
});